package com.agritech.chain;

/**
 * 安全处理器抽象类
 */
public abstract class SafetyHandler {
    protected SafetyHandler nextHandler;

    public void setNextHandler(SafetyHandler handler) {
        this.nextHandler = handler;
    }

    public abstract void handleSafetyEvent(SafetyEvent event);

    protected void passToNextHandler(SafetyEvent event) {
        if (nextHandler != null) {
            nextHandler.handleSafetyEvent(event);
        } else {
            System.out.println("没有更多的处理器可以处理该安全事件");
        }
    }
}